package com.example.qu_tao.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.qu_tao.View.CaiGouXinXiFragment;
import com.example.qu_tao.View.ShouMaiXinXiFragment;

public class MyPagerAdapter extends FragmentPagerAdapter {

    private static final int NUM_PAGES = 2;

    public MyPagerAdapter(@NonNull FragmentManager fm) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return new ShouMaiXinXiFragment();
            case 1:
                return new CaiGouXinXiFragment();
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return NUM_PAGES;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return "售卖信息";
            case 1:
                return "采购信息";
            default:
                return null;
        }
    }
}
